<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="./js/jquery-2.1.0.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/Global.js"></script>
    <style>
        .wrap {
            padding: 20px;
        }

        .select {
            height: 40px;
            /* border-bottom: 1px solid #ccc; */
            text-align: center;
        }

        .search {
            width: 200px;
            height: 38px;
            margin: 0 auto;
            display: inline-block;
            padding-top: 1px;

        }

        .layui-input {
            border: 0px;
            padding: 0;
            height: 100%;
            width: 100%;
            text-align: center;
        }

        .btn {
            display: inline-block;

        }

        .layui-table td {
            padding: 0px;
            height: 30px;
            line-height: 0px;
            text-align: center;
        }

        .layui-table td {
            margin: 0px;
        }

        .layui-form-item {
            margin: 0px;
            width: 100%;
            height: 100%;
        }

        .layui-form-item .layui-input-inline {
            width: 100%;
            margin: 0px !important;
            height: 100%;
        }

        .layui-unselect {
            height: 100%;
        }

        .layui-select-title {
            height: 100%;
        }

        h3 {
            text-align: center;
        }

        .winbody {
            padding: 20px;
            display: none;
        }

        .control {
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="wrap">

        <div class="select">
            <div class="search">
                <input class="layui-input" style="border:1px solid #ccc;" type="text" placeholder="客户编码 名称 车辆牌号">
            </div>
            <div class="btn">
                <button class="layui-btn layui-btn-normal">查询</button>
            </div>
        </div>
        <table id="table" lay-filter="table" class="layui-table">
            <thead>
                <tr>
                    <th>序号</th>
                    <th>客户名称</th>
                    <th>车辆牌号</th>
                    <th>自编号</th>
                    <th>车辆类型</th>
                    <th>车轴/轮数</th>
                    <th>胎压接口</th>
                    <th>GPS接口</th>
                    <th>GPS卡号</th>
                    <th>胎压卡号</th>
                    <th>GPS主机</th>
                    <th>胎压主机</th>
                    <th>GSM</th>
                    <th>后视镜</th>
                    <th>OBD</th>
                    <th>多媒体</th>
                    <th>行车记录仪</th>
                    <th>录入人</th>
                    <th>下发数据</th>
                    <th>初始密码</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody class="lists">
            </tbody>
        </table>
    </div>
    <div class="winbody">
        <table class="layui-table">
            <thead>
                <tr>
                    <th>接口</th>
                    <th>值</th>
                </tr>
            </thead>
            <tbody class="datalist">

            </tbody>
        </table>
    </div>
</body>
<script>
    // var layer = ''
    // layui.use('layer', function () {
    //     layer = layui.layer;
    //     var index = layer.load(1, {
    //         shade: [0.1, '#fff'] //0.1透明度的白色背景
    //     });
    // })

    layui.use('table', function () {
        var table = layui.table;
    })
    layui.use(['form', 'layedit', 'laydate'], function () {
        laydate = layui.laydate;
        laydate.render({
            elem: '.dddate'
        });
    })
    let arrs = ''
    $.ajax({
        url: `${API}/erpBidata/selBiData?userId=${loadUserInfo.user.id}&cs=`,
        type: 'get',
        success: function (res) {
            let arr = res.data
            arrs = res.data
            let str = ''
            $.each(arr, function (i) {
                if (i == 1) {
                    str = ''
                }
                let json = arr[i]
                str += `<tr><td>${i}</td>
                    
                    
                    <td>${json[4]}</td>
                    <td>${json[5]}</td>
                    <td>${json[6]}</td>
                    <td>${json[7]}</td>
                    <td>${json[8]}</td>
                    <td>${json[9] == '' ? ' ' : json[9]}</td>
                    <td>${json[10] == '' ? ' ' : json[10]}</td>
                    <td>${json[11] == '' ? ' ' : json[11]}</td>
                    <td>${json[12] == '' ? ' ' : json[12]}</td>
                    <td>${json[13]}</td>
                    <td>${json[14]}</td>
                    <td>${json[15]}</td>
                    <td>${json[16]}</td>
                    <td>${json[17]}</td>
                    <td>${json[18]}</td>
                    <td>${json[19]}</td>
                    <td>${json[20]}</td>
                    <td>启动</td>
                    <td>启动</td>
                    <td>
                        <div class="layui-btn layui-btn-xs"  onclick="update(${i},'${json[9]}lz-zl${json[10]}lz-zl${json[11]}lz-zl${json[12]}')">修改</div>
                    </td></tr>`

            })
            $('.lists').append(str)
        }
    })
    function update(indexs, a) {

        a = a.split('lz-zl')
        $('.datalist').html()
        $('.datalist').append(`<tr>
                    <td>胎压接口</td>
                    <td><input type="text" class="layui-input tyjk" value="${a[0]}"></td>
                </tr>
                <tr>
                    <td>GPS接口</td>
                    <td><input type="text" class="layui-input gpsjk" value="${a[1]}"></td>
                </tr>
                <tr>
                    <td>GPS卡号</td>
                    <td><input type="text" class="layui-input gpskh" value="${a[2]}"></td>
                </tr>
                <tr>
                    <td>胎压卡号</td>
                    <td><input type="text" class="layui-input tykh" value="${a[3]}"></td>
                </tr>`)
        layui.use('layer', function () {
            var layer = layui.layer;
            layer.open({
                type: 1,
                title: '修改',
                content: $('.winbody'),
                btn: ['保存'],
                yes: function (index, layero) {
                    arrs[index][9] = $('.tyjk').val()
                    arrs[index][10] = $('.gpsjk').val()
                    arrs[index][11] = $('.gpskh').val()
                    arrs[index][12] = $('.tykh').val()
                    console.log(arrs[index])
                    $.ajax({
                        url: `${API}/erpBidata/updateBidata`,
                        type: 'post',
                        data: {
                            ids: arrs[indexs][0],
                            values: arrs[indexs].toString()
                        },
                        success: function (res) {
                            layer.close(index);
                        }
                    })
                    // layer.close(index);
                }
            })
        })

    }

</script>

</html>